﻿using enyo;

namespace com.RexToy
{
    public class UnitConverter : enyo.Control
    {
        private new object[] components = new Control[]{
            new RadioGroup(){ kind = ControlKind.RadioGroup,
                components = new object[]{
                    new {kind = ControlKind.RadioButton, name = "temp", label = enyo.Global._L("Temperature"), idx = 0, onclick ="selectView"},
                    new {kind = ControlKind.RadioButton, name = "leng", label = enyo.Global._L("Length"), idx = 1, onclick ="selectView"},
                    new {kind = ControlKind.RadioButton, name = "wght", label = enyo.Global._L("Weight"), idx = 2, onclick ="selectView"},
                    new {kind = ControlKind.RadioButton, name = "area", label = enyo.Global._L("Area"), idx = 3, onclick ="selectView"},
                    new {kind = ControlKind.RadioButton, name = "volm", label = enyo.Global._L("Volume"), idx = 4, onclick ="selectView"},
                    new {kind = ControlKind.RadioButton, name = "engy", label = enyo.Global._L("Energy"), idx = 5, onclick ="selectView"},
                    new {kind = ControlKind.RadioButton, name = "angl", label = enyo.Global._L("Angle"), idx = 6, onclick ="selectView"},
                    new {kind = ControlKind.RadioButton, name = "pres", label = enyo.Global._L("Pressure"), idx = 7, onclick ="selectView"}
                }
            },

            new Pane(){kind = ControlKind.Pane, transitionKind = Transitions.LeftRightFlyin,
                components = new object[]{
                    new {kind= "com.RexToy.TempView"},
				    new {kind= "com.RexToy.LengView"},
				    new {kind= "com.RexToy.WghtView"},
				    new {kind= "com.RexToy.AreaView"},
				    new {kind= "com.RexToy.VolmView"},
				    new {kind= "com.RexToy.EngyView"},
				    new {kind= "com.RexToy.AnglView"},
				    new {kind= "com.RexToy.PresView"}
                }
            }
        };
	
        public void SelectView(object sender) {
            var pane = this._["pane"] as Pane;
            pane.SelectViewByIndex((int)sender["idx"], false);
        }
    }
}
